<?php
declare (strict_types = 1);

namespace app\xiangji\command;

use app\common\models\LoveScore;
use app\common\models\UserLover;
use app\xiangji\caches\ScoreRankCache;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class CacheLoverScore extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('cache:score')
            ->setDescription('缓存用户恩爱值');
    }

    protected function execute(Input $input, Output $output)
    {
        foreach (LoveScore::cursor() as $score){
            ScoreRankCache::userScore($score->user_id, $score->total_score);
        }
    	// 指令输出
    	$output->writeln('缓存用户恩爱值数据成功');
    }
}
